<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">人均参与截流统计</ui:define>
    <ui:define name="content">
        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false" draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:commandButton id="flush" value="刷新缓存" icon="fa fa-bolt"
                                         actionListener="#{activityAverageJoinInterceptStatBean.onFlushCache()}"
                                         update="@form"/>
                        <p:columnToggler datasource="statisticRecordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         rendered="#{activityAverageJoinInterceptStatBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="导出" ajax="false" icon="ui-icon-arrowthick-1-s">
					        <p:fileDownload value="#{activityAverageJoinInterceptStatBean.downloadExcel()}" />
					    </p:commandButton>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         rendered="#{activityAverageJoinInterceptStatBean.isNormal()}"
                                         actionListener="#{activityAverageJoinInterceptStatBean.onReset}"
                                         process="@this" update="@form"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="startDate" value="开始时间"/>
                                <p:calendar id="startDate" value="#{activityAverageJoinInterceptStatBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="selectProduct" value="产品"/>
                                <p:tree id="selectProduct" value="#{activityAverageJoinInterceptStatBean.prodNodeTree}" var="prod"
						                selectionMode="checkbox" style="text-align: left"
						                selection="#{activityAverageJoinInterceptStatBean.$.prodNodes}" 
						                animate="true" expanded="true" draggable="true" droppable="true"
						                dynamic="true"
						                filterBy="#{prod.name}"
                                		filterMatchMode="contains">
							        <p:treeNode icon="ui-icon-note">
							            <h:outputText value="#{prod.name}"/>
							        </p:treeNode>
						    	</p:tree>
						    	
						    	<p:outputLabel for="selectChannel" value="渠道"/>
                                <p:selectCheckboxMenu id="selectChannel" value="#{activityAverageJoinInterceptStatBean.$.channelIdList}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{activityAverageJoinInterceptStatBean.channelList}" var="channel"
                                    	itemValue="#{channel.channel_code}" itemLabel="#{channel.channel_name}"/>
                                </p:selectCheckboxMenu>
                                
                                <p:outputLabel for="selectUserType" value="用户类型"/>
                                <p:selectCheckboxMenu id="selectUserType" value="#{activityAverageJoinInterceptStatBean.$.userTypeList}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{activityAverageJoinInterceptStatBean.userTypeList}" var="userType"
                                    	itemValue="#{userType.userTypeId}" itemLabel="#{userType.userType}"/>
                                </p:selectCheckboxMenu>
                                
                                <p:outputLabel for="endDate" value="结束时间"/>
                                <p:calendar id="endDate" value="#{activityAverageJoinInterceptStatBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>
                                            
                                <p:outputLabel for="selectPlatform" value="平台"/>
                                <p:selectCheckboxMenu id="selectPlatform" value="#{activityAverageJoinInterceptStatBean.$.platformList}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{activityAverageJoinInterceptStatBean.platformList}" var="platform"
                                    	itemValue="#{platform.platformCode}" itemLabel="#{platform.platformName}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectAD" value="广告位ID"/>
                                <p:selectCheckboxMenu id="selectAD" value="#{activityAverageJoinInterceptStatBean.$.adIdList}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{activityAverageJoinInterceptStatBean.adList}" var="ad"
                                    	itemValue="#{ad.advertiseId}" itemLabel="#{ad.advertiseName}"/>
                                </p:selectCheckboxMenu>
                                
                                <p:outputLabel for="selectAC" value="活动"/>
                                <p:selectCheckboxMenu id="selectAC" value="#{activityAverageJoinInterceptStatBean.$.activityList}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{activityAverageJoinInterceptStatBean.activityList}" var="ac"
                                    	itemValue="#{ac.id}" itemLabel="#{ac.name}"/>
                                </p:selectCheckboxMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="statisticRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="statisticRecord"
                                         value="#{activityAverageJoinInterceptStatBean.lazyDataModel}"
                                         rows="20"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{activityAverageJoinInterceptStatBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="时间">
                                    <h:outputText value="#{statisticRecord.date}"/>
                                </p:column>
                                <p:column headerText="产品ID" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.productName}"/>
                                </p:column>
                                <p:column headerText="渠道" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.channelName}"/>
                                </p:column>
                                <p:column headerText="用户" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.userType}"/>
                                </p:column>
                                <p:column headerText="活动" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.activityName}"/>
                                </p:column>
                                <p:column headerText="广告Id" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.adName}"/>
                                </p:column>
                                <p:column headerText="平台" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.platform}"/>
                                </p:column>
                                <p:column headerText="日活UV" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.activityUv}"/>
                                </p:column>
                                <p:column headerText="登陆UV" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.loginUv}"/>
                                </p:column>
                                <p:column headerText="详情UV" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.showUv}"/>
                                </p:column>
                                <p:column headerText="参与UV" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.clickUv}"/>
                                </p:column>
                                <p:column headerText="详情/日活" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.perShowAct}"/>
                                </p:column>
                                <p:column headerText="参与/日活" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.perClickAct}"/>
                                </p:column>
                                <p:column headerText="参与/详情" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.perClickShow}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>